<?php
/**
 * Created by qinpeizhou.
 * Date: 2018/5/12
 * Time: 23:31
 * Email : 1031219129@qq.com
 * 基础模型类
 */

include_once( dirname(__FILE__).'/../library/Db/Db.php');
include_once( dirname(__FILE__).'/../library/Db/Db_c.php');
include_once( dirname(__FILE__).'/../library/Tools.php' );

class BaseModel
{
    protected $db=null; //主库连接标识
    protected $db_c=null; //从库连接标识

    public function __construct()
    {
        date_default_timezone_set('Asia/Shanghai');
        global $db, $db_c;
        $this->db = $db = new Db();
        $this->db_c = $db_c = new Db_c();
    }

    public function __destruct()
    {
        if( !empty($this->db) ) {
            $this->db->CloseConnection();
        }
        if( !empty($this->db_c) ) {
            $this->db_c->CloseConnection();
        }
        unset( $this->db, $this->db_c);
    }
}
